package com.danieldura.highrise.data
{
	import com.adobe.utils.DateUtil;
	
	public class Membership implements HighriseData
	{
		public var id:int;
		public var groupId:int;
		public var userId:int;
		public var createdAt:Date;
		public var updatedAt:Date;
		
		public function parse( data:XML ):void
		{
			id = data.id;
			groupId = data["group-id"];
			userId = data["user-id"];
			createdAt = DateUtil.parseW3CDTF( data["created-at"] );
			updatedAt = DateUtil.parseW3CDTF( data["updated-at"] );
		}
		
		public function toXML():XML
		{
			var data:XMl = new XML( <membership /> );
			data.id = id;
			data["group-id"] = groupId;
			data["user-id"] = userId;
			return data;
		}
		
		public function toXMLString():String
		{
			return toXML().toXMLString();
		}		
	}
}

/*
<membership>
  <id type="integer">1</id>
  <group-id type="integer">1</group-id>
  <user-id type="integer">1</user-id>
  <created-at type="datetime">2007-04-23T20:25:29Z</created-at>
  <updated-at type="datetime">2007-04-23T20:25:29Z</updated-at>
</membership>
*/